<!--  -->
<template>
  <div class="cartsMain1">
    <div v-for="item in carts">
      {{item.id}}
      {{item.title}}
      <button @click="setCartBuyNumFn">购买</button>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState,mapMutations } from "vuex";

export default {
  computed: {
    ...mapState({
      carts: state => state.carts.carts
    })
  },
  methods: {
    ...mapActions({
      setCartsFn: "carts/setCarts"
    }),
    ...mapMutations({
      setCartBuyNumFn:"carts/setCartBuyNum"
    })
  },

  data() {
    return {};
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.setCartsFn();
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {}
};
</script>
<style class="scss" scoped>
/* @import url(); 引入css类 */
</style>